using AutoMapper;
using SapaFinance.DTO;
using SapaFinance.Domain.Model;

namespace SapaFinance.OOMap.Helpers
{
    public class AccountToAccountDTOConvert : TypeConverter<Account, AccountDTO>
    {

        protected override AccountDTO ConvertCore(Account entity)
        {
            var dto = new AccountDTO();
            if (entity != null){
                dto.UID = entity.UID;
                dto.AccountNumber = entity.Number;
                dto.BankName = entity.Bank.Name;
                dto.CurrencyName = entity.Currency.Name;
                dto.Iban = entity.Iban;
                dto.Corporation = entity.Corporation.Name;
                dto.SelectedBank = entity.Bank.UID;
                dto.SelectedCurrency = entity.Currency.UID;
                dto.SelectedCorporation = entity.Corporation.UID;
                dto.IsHidden = entity.IsHidden;
                dto.IsPrimaryAccount = entity.IsPrimary;
                dto.IsHidden = entity.IsHidden;
                dto.Changed = entity.ChangedBy.DateTime;
                dto.ChangedBy = entity.ChangedBy.User.FullName;
                dto.Created = entity.CreatedBy.DateTime;
                dto.CreatedBy = entity.CreatedBy.User.FullName;
                dto.SelectedOwner = entity.OwnedBy.User.UID;

            }
            return dto;
        }
    }
}